package org.example.visitor;

public class PriceVisitor implements IVisitor{
    @Override
    public void visit(ChairProduct product) {
        //访问者模式需要数据的对象结构类型相对稳定不会改变,这里如果会变则不适合访问者模式
        product.setColor("kddddddddkdkdkd");
        System.out.println("visit " + product.getClass().getName() + "'s price " + product.getPrice());
    }

    @Override
    public void visit(DeskProduct product) {
        System.out.println("visit " + product.getClass().getName() + "'s price " + product.getPrice());
    }

    @Override
    public void visit(ComputerProduct product) {
        System.out.println("visit " + product.getClass().getName() + "'s price " + product.getPrice());
    }
}
